package com.gaussian.property.admin.module.system.service;

import com.gaussian.property.module.system.entity.SysLoginInfo;
import com.gaussian.property.module.system.entity.SysOperLog;
import com.gaussian.property.module.system.service.ISysLoginInfoService;
import com.gaussian.property.module.system.service.ISysOperLogService;
import com.songqi.common.core.constant.Constants;
import com.songqi.common.core.utils.BeanCopyUtil;
import com.songqi.common.log.domain.LoginInfoLog;
import com.songqi.common.log.domain.OperationInfoLog;
import com.songqi.common.log.service.LogApi;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author songqi(13776346982)
 */
@Service
public class LogApiImpl implements LogApi {

    @Resource
    private ISysLoginInfoService iSysLoginInfoService;

    @Resource
    private ISysOperLogService iSysOperLogService;
    @Override
    public void saveLoginLog(LoginInfoLog loginInfoLog) {
        // 封装对象
        SysLoginInfo sysLoginInfo = BeanCopyUtil.copyProperties(loginInfoLog, SysLoginInfo.class);
        sysLoginInfo.setSource(Constants.ADMIN_SOURCE);
        iSysLoginInfoService.insertLoginInfo(sysLoginInfo);
    }

    @Override
    public void saveOperationLog(OperationInfoLog operationInfoLog) {
        SysOperLog sysOperLog = BeanCopyUtil.copyProperties(operationInfoLog, SysOperLog.class);
        iSysOperLogService.insertOperlog(sysOperLog);
    }
}
